package databasePackage;

/**
 * This class is structure for all fields of an entry in the DB.
 * @author Marcelo Korn & Oleg Ruchlis
 **/
public class ListEntry {
    
    /**
     * Basic builder. create an empty entry
     */
    public ListEntry() {
        firstName       = "";
        lastName        = "";
        emailAddress    = "";
        username        = "";
        password        = "";
    }

    /**
     * Creates an entry with the provided values
     * @param firstName The name of the user
     * @param lastName last name of the user.
     * @param emailAddress email of the user.
     * @param username login of the user.
     * @param password password chosen for the login.
     */
    public ListEntry(String firstName, String lastName, String emailAddress, String username, String password) 
    {
        this.firstName      = firstName;
        this.lastName       = lastName;
        this.emailAddress   = emailAddress;
        this.username       = username;
        this.password       = password;
    }
    
    /**
     * Checking the validity of the entry (all members were provided)
     * @return boolean indicating the validity of the entry
     */
    public boolean checkValid()
    {
        // making sure all fields were provided.
        if( firstName   != null &&
            lastName    != null &&
            emailAddress!= null &&
            username    != null &&
            password    != null)
        {
            // triming all whitespaces
            firstName.trim();
            lastName.trim();
            emailAddress.trim();
            username.trim();
            password.trim();
            
            // making sure all fields aren't empty
            if( !firstName.equals("")   &&
                !lastName.equals("")    &&
                !emailAddress.equals("")&&
                !username.equals("")    &&
                !password.equals(""))
            
            return(true);
        }
        
        return (false);
    }
    /**
     * The name of the user.
     */
    public String firstName;
    /**
     * last name of the user.
     */
    public String lastName;
    /**
     * email of the user.
     */
    public String emailAddress;
    /**
     * login of the user.
     */
    public String username;
    /**
     * password chosen for the login.
     */
    public String password;
}

